package com.itheima.service;

import com.itheima.domain.Student;
import com.itheima.mapper.StudentMapper;
import com.itheima.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

/*
    需求: 在进行多表查询时
            1. 若使用班级信息,则查询班级表
            2. 若不用班级信息,不查询班级表,直接查询单个学生表 (查询单表效果高很多)
        策略:
            按需加载
            懒加载
            延迟加载

 */
public class StudentServiceTest {

    @Test
    public void findAll(){
        SqlSession sqlSession = MybatisUtils.getSqlSession();
        StudentMapper mapper = sqlSession.getMapper(StudentMapper.class);


        List<Student> list = mapper.findAll();
        for (Student student : list) {
            //System.out.println(student);
            // 注意: 此时没有使用班级信息
            System.out.println(student.getId() +"  "+student.getName());
        }

        sqlSession.close();

    }
}
